<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'在线问诊记录'),
);
if($_RQ['op']=='list'){
	$params=array('worker_id'=>$this->worker_id);
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_zhongyi_linelog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['is_addtitle']=$item['ispay']?'已支付':'未支付';
			$item['worker']=pdo_get('jy_zhongyi_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['worker_id']),array('lesson_id','storeid','name'));
			if($item['worker']['storeid']){
				$item['storetitle']=pdo_getcolumn('jy_zhongyi_store',array('id'=>$item['worker']['storeid']),'title');
			}
			$this->model('worker')->upmy_user($item['mid'],$item['bodyid'],$item['worker_id']);
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			array('name'=>'day','title'=>'问诊日期','type'=>'string'),
			array('name'=>'fee','title'=>'费用','type'=>'string'),
			array('name'=>'worker_id','title'=>'大夫','type'=>'select','options'=>'workers','option_title'=>'name'),
			array('name'=>'ispay','title'=>'支付状态','type'=>'radio','options'=>'ispay'),
		),'action'=>array(
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['workers']=pdo_getall('jy_zhongyi_worker',array('uniacid'=>$_SESSION['uniacid']),array('id','name'),'id');
	$return['ispay']=array('未支付','已支付');
	$return['htmls']=$htmls;
	
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_zhongyi_linelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}